#include<iostream>
#include<unistd.h>
#include<pthread.h>

using namespace std;

#define NUM 5

void* threadRun(void *name)
{
    while(true)
    {
        cout << "我是次线程 " << (char*)name << endl;
        sleep(1);
    }

    return nullptr;
}

int main()
{
    pthread_t pt[NUM];
    for(int i = 0; i < NUM; i++)
    {
        //注册新线程的信息
        char name[64];
        snprintf(name,sizeof(name),"thread_%d",i+1);
        pthread_create(pt+1,nullptr,threadRun,name);
    }

    while(true)
    {
        cout << "我是主线程，我正在运行" << endl;
        sleep(1);
    }

    return 0;
}